package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.RegDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @RequestMapping("/v1/user/login")
    @ResponseBody
    public String login(){
        return "恭喜你登录成功";
    }

    @ResponseBody
    @RequestMapping("/v1/user/reg1")
    public String reg1(HttpServletRequest request){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String nickname = request.getParameter("nickname");
        return username + ":" + password + ":" + nickname;
    }

    //通过设置参数的方法
    @ResponseBody
    @RequestMapping("/v1/user/reg2")
    public String reg2(String username,String password,String nickname){
        return username + ":" + password + ":" + nickname;
    }
    @ResponseBody
    @RequestMapping("/v1/user/reg3")
    public String reg3(RegDto regDto){
        return regDto.getUsername() + ":" + regDto.getPassword() + ":" + regDto.getNickname();
    }
}
